//
//  BaseNavigationController.m
//  SimpleNote
//
//  Created by mac on 2017/11/21.
//  Copyright © 2017年 上海LOL信息技术服务有限公司. All rights reserved.
//

#import "BaseNavigationController.h"
#import "UIBarButtonItem+SRExtension.h"


@interface BaseNavigationController ()

@end

@implementation BaseNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationBar.backgroundColor = UIColorFromRGB(0x1e90ff);
    self.navigationBar.barTintColor = UIColorFromRGB(0x1e90ff);
    // setting属性
    [self.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:18]}];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/**
 *  通过拦截push方法来setting每个push进来的控制器的返回按钮   http://www.cnblogs.com/gchlcc/p/5469350.html
 */
-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    // 如果push进来的不是第一个控制器
    if (self.childViewControllers.count > 0) {
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"titlebar_icon_goback" selectedImage:@"titlebar_icon_goback" addTarget:self action:@selector(backAction)];
        // 隐藏底部的工具条
        viewController.hidesBottomBarWhenPushed = YES;
    }
    // 一旦调用super的pushViewController方法,就会创建子控制器viewController的view并调用viewController的viewDidLoad方法。可以在viewDidLoad方法中重新setting自己想要的左上角按钮样式
    [super pushViewController:viewController animated:animated];
}

-(void)backAction{
    [self popViewControllerAnimated:YES];
}


@end






